<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="authz" uri="http://www.springframework.org/security/tags" %>
<%@ page import="org.springframework.security.ui.AbstractProcessingFilter" %>
<%@ page import="org.springframework.security.AuthenticationException" %>
<authz:authorize ifAllGranted="ROLE_USER">
  <c:redirect url="index.jsp"/>
</authz:authorize>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <link href="<c:url value="/main.css"/>" rel="stylesheet" type="text/css"/>
  <title>Micropayment Consumer</title>
</head>
<body>
<div id="container">
  <div id="content">
    <c:if test="${!empty sessionScope.SPRING_SECURITY_LAST_EXCEPTION}">
      <h1>Error</h1>
      <p class="error">Your login attempt was not successful. (<%= ((AuthenticationException) session.getAttribute(AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY)).getMessage() %>)</p>
    </c:if>
    <c:remove scope="session" var="SPRING_SECURITY_LAST_EXCEPTION"/>
    <authz:authorize ifNotGranted="ROLE_USER">
      <h1>Login</h1>
      <form action="<c:url value="/login.do"/>" method="POST">
        <p><label>Username: <input type='text' name='j_username' value="user01"></label></p>
        <p><label>Password: <input type='text' name='j_password' value="password01"></label></p>
        <p><input name="login" value="Login" type="submit"></p>
      </form>
    </authz:authorize>
    <p class="footer"><a href="http://www.gruposp2p.org">Energía y Red</a></p>
  </div>
</div>
</body>
</html>